"""用户通知公告表(SysUserNotice)的Pydantic模型

包含用于API接口的Base、Create、Update、Public模型
"""

from datetime import datetime
from typing import Optional

from pydantic import Field

from app.schemas.base import BaseSchema


class UserNoticeBase(BaseSchema):
    """用户通知公告表基础模型"""

    notice_id: int = Field(description="公共通知id", alias="noticeId")
    user_id: int = Field(description="用户id", alias="userId")
    is_read: Optional[int] = Field(default=None, description="读取状态（0: 未读, 1: 已读）", alias="isRead")


class UserNoticeCreate(UserNoticeBase):
    """创建用户通知公告表时使用的模型"""

    create_time: datetime = Field(description="创建时间")


class UserNoticeUpdate(UserNoticeBase):
    """更新用户通知公告表时使用的模型"""

    notice_id: Optional[int] = Field(default=None, description="公共通知id", alias="noticeId")
    user_id: Optional[int] = Field(default=None, description="用户id", alias="userId")
    is_read: Optional[int] = Field(default=None, description="读取状态（0: 未读, 1: 已读）", alias="isRead")
    read_time: Optional[datetime] = Field(default=None, description="阅读时间", alias="readTime")


class UserNoticePublic(UserNoticeBase):
    """用户通知公告表公开模型，用于API响应"""

    id: int = Field(alias="id", description="id")
    notice_id: int = Field(alias="noticeId", description="公共通知id")
    user_id: int = Field(alias="userId", description="用户id")
    create_time: datetime = Field(alias="createTime", description="创建时间")
    is_read: Optional[int] = Field(default=None, alias="isRead", description="读取状态（0: 未读, 1: 已读）")
    read_time: Optional[datetime] = Field(default=None, alias="readTime", description="阅读时间")
    update_time: Optional[datetime] = Field(default=None, alias="updateTime", description="更新时间")
